package com.be.beadmin.basicData.controller;

import com.be.beadmin.basicData.entity.Plant;
import com.be.beadmin.common.entity.PageEntity;
import com.be.beadmin.basicData.service.PlantService;
import com.be.beadmin.basicData.dto.input.PlantQueryCriteria;
import com.be.beadmin.basicData.dto.input.PlantDto;
import org.springframework.data.domain.Pageable;
import com.be.beadmin.common.utils.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
* @author chenwei
* @date 2022-12-22
**/
@RestController
public class PlantController {

    @Autowired
    private  PlantService plantService;


    @PostMapping(value = "/basicData/getPlantByPage")
    public ResultModel getPlantByPage(@RequestBody PageEntity pageEntity)  {
        return ResultModel.success(plantService.getPlantByPage(pageEntity)) ;
    }

    @PostMapping("/basicData/addPlant")
    public ResultModel addPlant(@RequestBody PlantDto plantDto){
        plantService.addPlant(plantDto);
        return ResultModel.success(ResultModel.ADD);
    }

    @PostMapping("/basicData/delPlant")
    public ResultModel delPlant(@RequestBody PlantDto plantDto){
        plantService.delPlant(plantDto.getId());
        return ResultModel.success(ResultModel.DELETE);
    }


    @PostMapping("/basicData/updatePlant")
    public ResultModel updatePlant(@RequestBody PlantDto plantDto){
        plantService.updatePlant(plantDto);
        return ResultModel.success(ResultModel.UPDATE);
    }
}